﻿using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace WinUITest.Pages
{
    [Menu("数据模版")]
    public sealed partial class DataTemplatePage : Page
    {
        public DataTemplatePage() => InitializeComponent();
    }
    public class MyDataTemplateSelector : DataTemplateSelector
    {
        public DataTemplate? DefaultTemplate { get; set; }
        public DataTemplate? OtherTemplate { get; set; }
        protected override DataTemplate? SelectTemplateCore(object item, DependencyObject container)
        {
            if (item is string itemString && itemString == "123")
            {
                return OtherTemplate ?? DefaultTemplate;
            }
            return DefaultTemplate;
        }
    }
}
